<template>
	<view class="flex-col page">
		<view class="flex-col">
			<view class="flex-col group">
				<view class="flex-row items-center section_3 space-x-30">
					<image class="image_6" :src="content.cover" />
					<text class="text_4">{{content.shop_name}}</text>
				</view>
				<view class="flex-row equal-division">
					<view class="flex-row items-center equal-division-item section_4 space-x-25" @click="data.show=true" >
						<image class="image_7" src="/static/icon1.png" />
						<text class="font_2">核销</text>
					</view>
					<view class="flex-row items-center equal-division-item_2 section_5 space-x-25" @click="toWallet">
						<image class="image_7" src="/static/icon2.png" />
						<text class="font_2">我的钱包</text>
					</view>
				</view>
			</view>
			<view class="flex-col section_6">
				<text class="self-start text_5">常用工具</text>
				<view class="flex-row equal-division_2 group_2">
					<view class="flex-col items-center group_3 equal-division-item_3 space-y-26" @click="toServers">
						<image class="image_8" src="/static/service.png" />
						<text class="font_3">商家服务</text>
					</view>
					<view class="flex-col items-center group_3 equal-division-item_3 space-y-26" @click="toShop">
						<image class="image_8" src="/static/icon3.png" />
						<text class="font_3">店铺设置</text>
					</view>
					<!-- <view class="flex-col items-center group_4 equal-division-item_3 space-y-26" @click="toeRaluate"> 
						<image class="image_9" src="/static/icon4.png" />
						<text class="font_3">店铺评价</text>
					</view> -->
					<view class="flex-col items-center group_4 equal-division-item_3 space-y-26" @click="toSetUp"> 
						<image class="image_8" src="/static/icon5.png" />
						<text class="font_3">设置</text>
					</view>
				</view>
			</view>
		</view>
	</view>
	<u-popup :show="data.show" :round="10" :closeable="true" mode="center" @close="data.show=false">
		<view class=""  style="padding:40rpx;pa">
			<div class="title" style="height: auto;margin-top: 0;margin-bottom: 40rpx;">请输入核销码</div>
			<view class="popupInput">
				<input type="text" placeholder="请输入" v-model="data.use_sn">
			</view>
			<view class=" flex-row justify-around items-center">
				<view class="btnLeft flex-row justify-center items-center" @click="data.show=false">取消</view>
				<view class="btnLeft btnBg flex-row justify-center items-center" @click="getUse">确定</view>
			</view>
		</view>
	</u-popup>
	<u-popup :show="data.show1" :round="10" :closeable="true" mode="center" @close="data.show1=false">
		<view class=""  style="padding:40rpx;pa">
			<div class="title" style="height: auto;margin-top: 0;margin-bottom: 40rpx;">请输入核销码</div>
			<view class="flex-row justify-between">
				<view class="flex-row items-center space-x-18">
					<image class="image_7" :src="data.usePage.cover_path" />
					<view class="flex-col items-start space-y-67" style="width: 83%;">
						<text class="font_6 text_6">{{data.usePage.service_name}}</text>
						<view class="flex-row items-center justify-between" style="width: 100%;">
							<view class="group_3">
								<text class="font_9">￥</text>
								<text class="font_7">{{data.usePage.price}}</text>
							</view>
							<text class="self-start font_8">数量：×{{data.usePage.quantity}}</text>
						</view>
						
					</view>
				</view>
			</view>
			<view class="flex-row justify-between items-center font11" style="margin-top: 40rpx;">
				<text>订单号</text>
				<text>{{data.usePage.order_sn}}</text>
			</view>
			<view class="flex-row justify-between items-center font11">
				<text>下单时间</text>
				<text>{{data.usePage.create_time}}</text>
			</view>
			<view class="flex-row justify-between items-center font11">
				<text>支付方式</text>
				<text>{{data.usePage.payment_name}}</text>
			</view>
			<view class="flex-row justify-between items-center font11" style="margin-bottom: 40rpx;">
				<text>手机号</text>
				<text>{{data.usePage.mobile}}</text>
			</view>
			<view class=" flex-row justify-around items-center">
				<view class="btnLeft btnBg flex-row justify-center items-center" style="width: 490rpx;" @click="getUse">确定</view>
			</view>
		</view>
	</u-popup>
</template>

<script setup>
	import {
		onShow
	} from "@dcloudio/uni-app";
	import {
		onMounted,
		ref,
		reactive,
		getCurrentInstance
	} from "vue"
	const {
		proxy
	} = getCurrentInstance()
	let shop_id = ref('')
	let content = ref({})
	let read = ref('')
	let statusNum = ref({})
	let list = ref([])
	let data = ref({
		show: false,
		show1: false,
		use_sn:'',
		usePage:{}
	})

	onShow(() => {
		// uni.setStorageSync('shop_id',1)
		console.log(uni.getStorageSync('shop_id'));
		if (uni.getStorageSync('shop_id')) {
			shop_id.value = uni.getStorageSync('shop_id')
			getDate()
		} else {
			shop_id.value = ''
		}
	})
	const getDate = () => {
		proxy.$req.requestPOST(proxy.$api.CenterInfo.getInfo,{
			shop_id:uni.getStorageSync('shop_id')
		}).then(res => {
			if (res.flag == "success") {
				content.value = res.data
			}
		})
		// proxy.$req.requestPOST(proxy.$api.CenterInfo.orderStat).then(res => {
		// 	if (res.flag == "success") {
		// 		statusNum.value = res.data
		// 	}
		// })
	}
	const getDate1 = () => {
		proxy.$req.requestPOST(proxy.$api.WorkerCenterInfo.noRead).then(res => {
			if (res.flag == "success") {
				read.value = res.data.count
			}
		})
	}
	const getUse =()=>{
		proxy.$req.requestPOST(proxy.$api.OrderInfoInfo.usePage, {
			use_sn: data.value.use_sn,
			shop_id: uni.getStorageSync('shop_id') || '',
		}).then(res => {
			console.log(res)
			if(res.flag=="success"){
				data.value.show=false
				data.value.usePage=res.data
				data.value.show1=true
			}else{
				data.value.show=false
				uni.showToast({
					title:res.message,
					icon:'none'
				})
			}
		})
	}
	const toUse = () => {
		proxy.$req.requestPOST(proxy.$api.OrderInfoInfo.doUse, {
			use_sn: data.value.use_sn,
			shop_id: uni.getStorageSync('shop_id') || '',
		}).then(res => {
			console.log(res)
			uni.showToast({
				title:res.message,
				icon:'none'
			})
			if(res.flag=="success"){
				data.value.show=false
			}
		})
	}
	const toLogin = () => {
		uni.navigateTo({
			url: '/pages/login/login'
		})
	}
	const toServers =()=>{
		uni.navigateTo({
			url: '/pages/servers/servers'
		})
	}
	const toDetail = () => {
		uni.navigateTo({
			url: '/pages/mineDetail/mineDetail'
		})
	}
	const toShop = () => {
		if (!uni.getStorageSync('shop_id')) {
			uni.showToast({
				title: "请先登录！",
				icon: 'none'
			})
			setTimeout(() => {
				toLogin()
			}, 1000)
			return
		}
		uni.navigateTo({
			url: '/pages/shop/shop'
		})
	}
	const toWallet = () => {
		if (!uni.getStorageSync('shop_id')) {
			uni.showToast({
				title: "请先登录！",
				icon: 'none'
			})
			setTimeout(() => {
				toLogin()
			}, 1000)
			return
		}
		uni.navigateTo({
			url: '/pages/wallet/wallet'
		})
	}
	const toeRaluate = () => {
		if (!uni.getStorageSync('shop_id')) {
			uni.showToast({
				title: "请先登录！",
				icon: 'none'
			})
			setTimeout(() => {
				toLogin()
			}, 1000)
			return
		}
		uni.navigateTo({
			url: '/pages/evaluate/evaluate'
		})
	}
	const toSetUp = () => {
		uni.navigateTo({
			url: '/pages/setUp/setUp'
		})
	}
</script>

<style scoped lang="scss">
	.page {
		background-color: #f8f8f8;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100vh;

		.group {
			padding-bottom: 30rpx;
			// height: 572rpx;

			.section {
				padding: 34rpx 28rpx 29rpx 63rpx;
				background-color: #ffffff00;

				.font_1 {
					font-size: 28rpx;
					font-family: PingFangSC;
					letter-spacing: 1.4rpx;
					color: #ffffff;
				}

				.text {
					line-height: 21rpx;
				}

				.text_2 {
					line-height: 15rpx;
				}

				.pos {
					position: absolute;
					left: 20rpx;
					bottom: 3rpx;
				}

				.space-x-8 {

					&>view:not(:first-child),
					&>text:not(:first-child),
					&>image:not(:first-child) {
						margin-left: 8rpx;
					}

					.image {
						width: 36rpx;
						height: 24rpx;
					}

					.image_2 {
						width: 32rpx;
						height: 22rpx;
					}

					.image_3 {
						width: 50rpx;
						height: 24rpx;
					}
				}
			}

			.section_2 {
				padding: 26rpx 36rpx;
				background-color: #ffffff00;

				.image_4 {
					width: 24rpx;
					height: 24rpx;
				}

				.pos_2 {
					position: absolute;
					left: 36rpx;
					top: 50%;
					transform: translateY(-50%);
				}

				.text_3 {
					color: #333333;
					font-size: 36rpx;
					font-family: PingFangSC;
					line-height: 35rpx;
				}

				.image_5 {
					width: 34rpx;
					height: 6rpx;
				}

				.pos_3 {
					position: absolute;
					right: 38rpx;
					top: 50%;
					transform: translateY(-50%);
				}
			}

			.section_3 {
				padding: 42rpx 40rpx 150rpx;
				background-color: #54bc6e;
				background-image: linear-gradient(0deg, #f8f8f8 0%, #eff5f0 100%);

				.image_6 {
					border-radius: 20rpx;
					width: 196rpx;
					height: 148rpx;
				}

				.text_4 {
					color: #333333;
					font-size: 40rpx;
					font-family: PingFangSC;
					line-height: 38rpx;
				}
			}

			.space-x-30 {

				&>view:not(:first-child),
				&>text:not(:first-child),
				&>image:not(:first-child) {
					margin-left: 30rpx;
				}
			}

			.equal-division {
				position: relative;
				margin: -96rpx 30rpx 0;

				.equal-division-item {
					position: relative;
					flex: 1 1 330rpx;

					.pos_4 {
						position: absolute;
						left: 32rpx;
						top: 50%;
						transform: translateY(-50%);
					}
				}

				.section_4 {
					padding: 34rpx;
					border-radius: 20rpx;
					background-image: url('https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/6529eed0ce83440011a2f022/16972496151356569927.png');
					background-size: 100% 100%;
					background-repeat: no-repeat;
					height: 122rpx;
				}

				.equal-division-item_2 {
					position: relative;
					flex: 1 1 330rpx;
					margin-left: 30rpx;
				}

				.section_5 {
					padding: 34rpx;
					border-radius: 20rpx;
					background-image: url('https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/6529eed0ce83440011a2f022/16972496152100154131.png');
					background-size: 100% 100%;
					background-repeat: no-repeat;
					height: 122rpx;
				}

				.space-x-25 {

					&>view:not(:first-child),
					&>text:not(:first-child),
					&>image:not(:first-child) {
						margin-left: 25rpx;
					}
				}

				.image_7 {
					width: 72rpx;
					height: 72rpx;
				}

				.font_2 {
					font-size: 30rpx;
					font-family: PingFangSC;
					line-height: 29rpx;
					color: #333333;
				}
			}
		}

		.section_6 {
			margin: 0 30rpx;
			padding: 36rpx 0 28rpx;
			background-color: #ffffff;
			border-radius: 30rpx;

			.text_5 {
				margin-left: 32rpx;
				color: #333333;
				font-size: 32rpx;
				font-family: PingFangSC;
				line-height: 30rpx;
			}

			.equal-division_2 {
				margin-top: 42rpx;

				.group_3 {
					flex: 1 1 219rpx;
				}

				.equal-division-item_3 {
					padding: 10rpx 0 14rpx;
				}

				.space-y-26 {

					&>view:not(:first-child),
					&>text:not(:first-child),
					&>image:not(:first-child) {
						margin-top: 26rpx;
					}
				}

				.group_4 {
					flex: 1 1 219rpx;
					margin-left: 16rpx;

					.image_9 {
						border-radius: 10rpx;
						width: 48rpx;
						height: 48rpx;
					}
				}

				.font_3 {
					font-size: 25rpx;
					font-family: PingFang SC;
					line-height: 24rpx;
					color: #666666;
				}

				.image_8 {
					width: 48rpx;
					height: 48rpx;
				}
			}

			.group_2 {
				padding: 0 16rpx;
			}
		}

		.equal-division_3 {
			margin-top: 627rpx;

			.section_8 {
				flex: 1 1 375rpx;

				.image_10 {
					width: 32rpx;
					height: 32rpx;
				}

				.font_4 {
					font-size: 25rpx;
					font-family: PingFangHeiTC;
					line-height: 24rpx;
					color: #54bc6e;
				}

				.text_6 {
					font-size: 24rpx;
					line-height: 23rpx;
				}
			}

			.equal-division-item_4 {
				padding: 20rpx 0 12rpx;
				background-color: #ffffff;
				height: 100rpx;
			}

			.space-y-15 {

				&>view:not(:first-child),
				&>text:not(:first-child),
				&>image:not(:first-child) {
					margin-top: 15rpx;
				}
			}
		}

		.section_7 {
			background-color: #ffffff;
			border-top: solid 2rpx #f6f6f6;
		}
	}
	.font11 {
		font-size: 30rpx;
		font-family: PingFangSC;
		line-height: 30rpx;
		color: #333;
		margin: 22rpx 0;
	}
	.space-x-18 {
	
		&>view:not(:first-child),
		&>text:not(:first-child),
		&>image:not(:first-child) {
			margin-left: 18rpx;
		}
	
		.image_7 {
			border-radius: 20rpx;
			width: 160rpx;
			height: 160rpx;
		}
	
		.space-y-67 {
	
			&>view:not(:first-child),
			&>text:not(:first-child),
			&>image:not(:first-child) {
				margin-top: 67rpx;
			}
	
			.text_6 {
				margin-left: 6rpx;
			}
	
			.group_3 {
				line-height: 25rpx;
	
				.font_9 {
					font-size: 24rpx;
					font-family: PingFangSC;
					line-height: 19rpx;
					color: #ff3333;
				}
	
				.font_7 {
					font-size: 32rpx;
					font-family: PingFangSC;
					line-height: 25rpx;
					color: #ff3333;
				}
			}
		}
	}
	
	.font_8 {
		font-size: 24rpx;
		font-family: PingFang SC;
		line-height: 23rpx;
		color: #999999;
	}
	
	.text_7 {
		margin-top: 117rpx;
	}
	.title {
		width: 100%;
		height: 90rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		margin-top: 19rpx;
	}
	.popupInput{
		width: 100%;
		background: #F6F8FA;
		border-radius: 10rpx;
		padding: 20rpx 30rpx;
		margin-top: 20rpx;
		margin-bottom: 45rpx;
		>input{
			width: 100%;
			color: #333;
		}
	}
	.btnLeft{
		width: 240rpx;
		height: 88rpx;
		border: 2px solid #BDBDBD;
		border-radius: 24rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
		margin-right: 20rpx;
	}
	.btnBg{
		background: #54BC6E;
		border: 2px solid #54BC6E;
		color: #FFFFFF;
		margin-right: 0rpx;
	}
</style>